package com.smart.terminal.ftp;

import com.jcraft.jsch.ChannelSftp;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

/**
 * sftp - 连接池
 *
 * @author wf
 * @version 1.0.0
 * @since 2022/11/10
 */
public class SftpGenericObjectPool {

    private final GenericObjectPool<ChannelSftp> genericObjectPool;

    public SftpGenericObjectPool(SftpFactory sftpFactory, GenericObjectPoolConfig<ChannelSftp> poolConfig) {
        this.genericObjectPool = new GenericObjectPool<>(sftpFactory, poolConfig);
    }

    public ChannelSftp borrowObject() throws Exception {
        return genericObjectPool.borrowObject();
    }

    public void returnObject(ChannelSftp obj) {
        genericObjectPool.returnObject(obj);
    }
}


